package com.example.exception;

import cn.dev33.satoken.exception.DisableServiceException;
import cn.dev33.satoken.exception.NotRoleException;
import com.example.model.Result;
import com.example.model.vo.ResultVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


/**
 * @author zhexueqi
 * @ClassName GlobalHandlerException
 * @since 2025/4/8    13:19
 */
@ControllerAdvice
public class GlobalHandlerException {

    @ExceptionHandler(BusinessException.class)
    public Result<Object> handleBusinessException(BusinessException ex) {
        return Result.error(ex.getCode(), ex.getMessage());
    }

    @ExceptionHandler(DisableServiceException.class)
    public Result<Object> handleDisableServiceException(DisableServiceException ex) {
        return Result.error(ex.getCode(), ex.getMessage());
    }

    @ExceptionHandler(NotRoleException.class)
    public Result<Object> handleNotRoleException(NotRoleException ex) {
        return Result.error(ex.getCode(), ex.getMessage());
    }
}